﻿/**
* ibio-develop
* Thu Mar 27 11:43:12 2008
*/

class DateConv{
	//vtm<=>video time mark string
	static public function sec2vtm(sec:Number):String{
		var ms=(sec-Math.floor(sec))*1000;
		var d=new Date(0,0,0,0,0,sec,ms);
		var currDate = d.getHours() + ':'
					   + (d.getMinutes()<10?'0'+d.getMinutes():d.getMinutes())+':'
					   + (d.getSeconds()<10?'0'+d.getSeconds():d.getSeconds());
					   //+'.'+d.getMilliseconds();
		return currDate;
	}
	
	static public function vtm2sec(vtm:String):Number{
		var l=vtm.split(':',3).reverse();
		var s=0;
		var m=0;
		var h=0;
		var ms=0;
		for(var i=0;i<l.length;i++){
			if(i==0){
				var ts=new Number(l[i]);
				s=Math.floor(ts);
				ms=(ts-s)*1000;
			}
			if(i==1){
				m=new Number(l[i]);
			}
			if(i==2){
				h=new Number(l[i]);
			}
		}
		return h*60*60+m*60+s+ms/1000;
	}
}